<template>
<div class="gradient-info-cp box-shadow_2">
    <div class="top">
        <div 
            class="top"
            :style="dataInfo.gradient">
            <div class="bt-list">
                <Copy
                    title="css"
                    :content="dataInfo.gradient">
                </Copy>
                <ThemeBg
                    :background="dataInfo.gradient">
                </ThemeBg>
            </div>
            <div class="last-and-next">
                <LastNext
                    @onLast="onLast"
                    @onNext="onNext"
                    :lastState="lastData!=0"
                    :nextState="nextData!=0">
                </LastNext>
            </div>
        </div>
    </div>
    <div class="title">
        {{dataInfo.name}}
    </div>
    <div class="color-list">
        <ColorList
            :colorList="dataInfo.gradient">
        </ColorList>
    </div>
    <div class="bottom">
        <div class="left">
            <div class="item bt">
                <Like
                    type="gradient"
                    :dataInfo="itemData"
                    :number="itemData.like">
                </Like>
            </div>
            <div class="item bt">
                <LinkBt
                    :link_data = "$route.path">
                </LinkBt>
            </div>
            <div class="item tag">
                <Tags
                    :tags="dataInfo.tags"
                    :type="2">
                </Tags>
            </div>
        </div>
        <div class="right">
            <Date
                :date_data="dataInfo.init_date">
            </Date>
        </div>
    </div>
</div>
</template>

<script>
//渐变色详情展示组件
import Like from '@/components/other/Like';
import LinkBt from '@/components/other/Link';
import Date from '@/components/other/Date';
import Tags from '@/components/other/Tags';
import Copy from '@/components/other/Copy';
import LastNext from '@/components/other/LastNext';
import ThemeBg from '@/components/other/ThemeBg';
import ColorList from '@/components/other/ColorList';
export default {
    components: {
        Like,
        Date,
        LinkBt,
        ColorList,
        Tags,
        Copy,
        LastNext,
        ThemeBg,
    },
    props:{
        dataInfo:{ //对象数据
            type:Object,
            default:()=>{
                return {};
            },
        },
        lastData:{  //上一个gradient ID
            type:Number,
            default:0,
        },
        nextData:{
            type:Number,
            default:0,
        },
    },
    data(){
        return{
        };
    },
    methods:{
        onLast(){
            if(!this.lastData) return;
            this.$router.push({
                name:"Gradient",
                params:{
                    id:this.lastData,
                },
            }).catch(() => {return;});
        },
        onNext(){
            if(!this.nextData) return;
            this.$router.push({
                name:"Gradient",
                params:{
                    id:this.nextData,
                },
            }).catch(() => {return;});
        },
    },
}
</script>
<style lang="scss" scoped>
.gradient-info-cp{
    width: 100%;
    border: none;
    background-color: white;
    padding: 15px;
    box-sizing: border-box;
    border-radius: 5px;
    >.top{
        border-radius: 5px;
        overflow: hidden;
        >.top{
            position: relative;
            height: 400px;
            width: 100%;
            margin: 0 auto;
            border-radius: 5px;
            transition: all 0.2s;
            >.bt-list{
                display:flex;
                width: fit-content;
                position: absolute;
                bottom: 5px;
                left: 5px;
                opacity: 0;
                transition: all 0.2s;
                >div{
                    margin-right:5px;
                }
                /deep/.Copy{
                    border-radius: 3px;
                    font-weight: bold;
                }
                /deep/.ThemeBg{
                    border-radius: 3px;
                }
            }
            &:hover{
                margin: 0 auto;
                >.bt-list{
                    opacity: 1;
                }
            }
            >.last-and-next{
                position: absolute;
                top: 0;
                right: 0;
                height: 100%;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                padding: 10px;
                box-sizing: border-box;
                width: fit-content;
                opacity: 0;
                transition: all 0.2s;
                &:hover{
                    opacity: 1;
                }
            }
        }
    }
    >.title{
        font-size: 1.1rem;
        line-height: 1.1rem;
        font-weight: bold;
        margin-top: 15px;
        display:none;
    }
    /deep/.color-list{
        background-color: #ffffff;
        >div{
            >div{
                margin: 0 7.5px;
                margin-top: 15px;
            }
        }
    }
    >.bottom{
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 15px;
        >.left{
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            >.item{
                margin-right: 15px;
            }
            >.bt{
                /deep/div{
                    padding: 10px 15px;
                }
            }
            >.tag{
                span{
                    font-size: 1.1rem;
                    color: #899bb4;
                    margin-right: 15px;
                    cursor: pointer;
                    transition: all 0.2s;
                    &:hover{
                        color: #535f6e;
                    }
                }
            }
        }
        >.right{
            /deep/.Date{
                font-size: 1.2rem;
                line-height: 1.2rem;
                font-weight: bold;
            }
        }
    }
}
</style>

